package com.ease.util.events {

   import flash.events.Event;

   /**
    * A general error notifying event.
    */
   public class ErrorEvent extends Event {
      /** The default event type id. */
      public static const REQUEST_ID:String = "errorOccurred";

      /**
       * A flag for the errorStatus property, indicating that the error contained in this
       * event was delivered to some error handler.
       */
      public static const ERROR_DELIVERED:uint = 1 << 0;

      /** The error whose occurrence is being notified by this event. */
      public var error:Error;

      [Optional]
      /**
       * The event that represents the original cause, trigger or details of the error, if
       * any.
       */
      public var originalEvent:Event;

      [Optional]
      /**
       * For errors that occur in response to some request, this property represents the
       * entity that made the request.
       */
      public var errorTarget:Object;

      /** Indicates the processing that the error may have gone through. */
      public var errorStatus:uint = 0;

      /** Initializes an instance of this class. */
      public function ErrorEvent( error:Error = null, originalEvent:Event = null,
                                  errorTarget:Object = null,
                                  errorStatus:uint = 0,
                                  eventType:String = REQUEST_ID ):void {
         super( eventType );
         this.error = error;
         this.originalEvent = originalEvent;
         this.errorTarget = errorTarget;
         this.errorStatus = errorStatus;
      }

      /** Creates a clone of this event. */
      public override function clone():Event {
         return new ErrorEvent( this.error, this.originalEvent, this.errorTarget,
            this.errorStatus, this.type );
      }
   } // class

} // package
